#!/usr/bin/env python
#!conding:utf-8
"""
author:Johnson
date: 2017/5/17 14:30
version: v1.0
description:
    日志相关信息
    废弃，可以直接使用flask内置的日志配置
"""
import logging
from logging.config import fileConfig
from blog import app

AppLog = logging.getLogger('app_log')

__logfile__ = app.config['LOG_FILE']

# for dictConfig

logging.config.dictConfig({
    'version': 1,
    'disable_existing_loggers': False,  # this fixes the problem

    'formatters': {
        'standard': {
            'format': '[%(asctime)s] %(name)s <%(module)s> %(levelname)s:  %(message)s'
        },
    },
    'handlers': {
        'console': {
            'level':'DEBUG',
            'class':'logging.StreamHandler',
            'formatter':'standard',
        },
        'file':{
                'class': 'logging.FileHandler',
                'filename': __logfile__,
                'mode': 'a',
                'encoding':'utf-8',
                'formatter': 'standard',

        },
    },
    'loggers': {
        'app_log': {
            'handlers': ['console','file'],
            'level': 'DEBUG',
            'propagate': True
        }
    }
})